package cn.sunan.basic.config.service.impl;

import cn.sunan.basic.config.mapper.BesaMapper;
import cn.sunan.basic.config.query.BesaQuery;
import cn.sunan.basic.config.service.BesaService;
import cn.sunan.basic.uitl.PageList;
import cn.sunan.org.domain.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class BesaServiceimpl<T> implements BesaService<T> {
    @Autowired
    private BesaMapper<T> besaMapper;


    @Override
    public List selectAll() {
        return besaMapper.selectAll();
    }

    @Override
    public T selctById(Long id) {
        return besaMapper.selctById(id);
    }

    @Override
    public void save(T t) {
        besaMapper.save(t);
    }

    @Override
    public void update(T t) {
        besaMapper.update(t);
    }

    @Override
    public void delete(Long id) {
        besaMapper.delete(id);
    }

    @Override
    public PageList<T> queryByPage(BesaQuery besaQuery) {

        PageList<T> list = new PageList<>();
        //查询当前页数
        List<T> rows = besaMapper.selectpage(besaQuery);
        System.out.println(rows);
        list.setRows(rows);
        //统计条数
        Long total = besaMapper.count(besaQuery);
        list.setTotal(total);
        return list;
    }

    @Override
    public void batchDetele(List ids) {
        besaMapper.batchDelete(ids);
    }
}
